<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT">










<meta name="description" content="汇编语言源程序格式汇编源程序结构特点 汇编语言程序由若干个段组成。 各段顺序任意，段的数目依据需要而定。 类型有数据段、代码段、堆栈段、附加段。   段由若干语句组成,一条语句通常写成一行。 整个源程序以END为结尾。 需要独立运行的程序至少包含一个代码段, 并指明一个启动标号, 作为程序执行时的入口地址。  语句类型指令性语句格式：[标号:]  &amp;lt;指令助记符&amp;gt;  [操作数]  [;注">
<meta name="keywords" content="STM32,c++,Java,电子设计,Linux">
<meta property="og:type" content="article">
<meta property="og:title" content="汇编语言程序设计">
<meta property="og:url" content="https://hxk0912.github.io/2020/04/01/汇编语言程序设计/index.html">
<meta property="og:site_name" content="侯学凯的博客">
<meta property="og:description" content="汇编语言源程序格式汇编源程序结构特点 汇编语言程序由若干个段组成。 各段顺序任意，段的数目依据需要而定。 类型有数据段、代码段、堆栈段、附加段。   段由若干语句组成,一条语句通常写成一行。 整个源程序以END为结尾。 需要独立运行的程序至少包含一个代码段, 并指明一个启动标号, 作为程序执行时的入口地址。  语句类型指令性语句格式：[标号:]  &amp;lt;指令助记符&amp;gt;  [操作数]  [;注">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2020-09-04T03:23:03.411Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="汇编语言程序设计">
<meta name="twitter:description" content="汇编语言源程序格式汇编源程序结构特点 汇编语言程序由若干个段组成。 各段顺序任意，段的数目依据需要而定。 类型有数据段、代码段、堆栈段、附加段。   段由若干语句组成,一条语句通常写成一行。 整个源程序以END为结尾。 需要独立运行的程序至少包含一个代码段, 并指明一个启动标号, 作为程序执行时的入口地址。  语句类型指令性语句格式：[标号:]  &amp;lt;指令助记符&amp;gt;  [操作数]  [;注">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hxk0912.github.io/2020/04/01/汇编语言程序设计/">





  <title>汇编语言程序设计 | 侯学凯的博客</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="default">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">侯学凯的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">一个大学生的技术博客</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

<script>
    
    window.onload = function(){
        var path = 'https://hxk0912.github.io'; //这里要改成你博客的地址
        var localhostItem = String(window.location).split(path)[1];
        var LiNode = document.querySelectorAll('#menu > li > a')
        
        for(var i = 0; i< LiNode.length;i++){
            var item = String(LiNode[i].href).split(path)[1];
            if(item == localhostItem && item != undefined){
                LiNode[i].setAttribute('style','border-bottom:1px solid black');
            }
        }
    };

</script>


 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://hxk0912.github.io/2020/04/01/汇编语言程序设计/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Kai">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="侯学凯的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">汇编语言程序设计</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2020-04-01T15:01:24+08:00">
                2020-04-01
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/微机原理与接口技术/" itemprop="url" rel="index">
                    <span itemprop="name">微机原理与接口技术</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="汇编语言源程序格式"><a href="#汇编语言源程序格式" class="headerlink" title="汇编语言源程序格式"></a>汇编语言源程序格式</h2><h3 id="汇编源程序结构特点"><a href="#汇编源程序结构特点" class="headerlink" title="汇编源程序结构特点"></a>汇编源程序结构特点</h3><ul>
<li>汇编语言程序由若干个段组成。<ul>
<li>各段顺序任意，段的数目依据需要而定。</li>
<li>类型有数据段、代码段、堆栈段、附加段。</li>
</ul>
</li>
<li>段由若干语句组成,一条语句通常写成一行。</li>
<li>整个源程序以END为结尾。</li>
<li>需要独立运行的程序至少包含一个代码段, 并指明一个启动标号, 作为程序执行时的入口地址。</li>
</ul>
<h3 id="语句类型"><a href="#语句类型" class="headerlink" title="语句类型"></a>语句类型</h3><h4 id="指令性语句"><a href="#指令性语句" class="headerlink" title="指令性语句"></a>指令性语句</h4><p>格式：<code>[标号:]  &lt;指令助记符&gt;  [操作数]  [;注释]</code></p>
<ul>
<li>可执行语句, 用于表达处理器指令, 汇编后对应一条指令机器码→目标代码</li>
</ul>
<h4 id="指示性语句"><a href="#指示性语句" class="headerlink" title="指示性语句"></a>指示性语句</h4><p>格式：<code>[符号名]  &lt;伪指令助记符&gt;  [操作数]  [;注释]</code></p>
<ul>
<li>不可执行语句, 汇编时不产生目标代码。</li>
<li>又称伪指令, 用于指示汇编程序如何编译源程序。</li>
</ul>
<h3 id="指令与伪指令"><a href="#指令与伪指令" class="headerlink" title="指令与伪指令"></a>指令与伪指令</h3><ul>
<li><p>指令(instruction)</p>
<ul>
<li>让CPU产生动作, 在程序执行时才处理。</li>
<li>就是第3章学习的处理器指令, 与具体的处理器有关, 与汇编程序无关。</li>
</ul>
</li>
<li><p>伪指令(directive)</p>
<ul>
<li>不产生CPU动作, 在程序执行前由汇编程序处理。</li>
<li>与具体的处理器类型无关, 但与汇编程序有关。</li>
<li>不同版本的汇编程序支持不同的伪指令。</li>
</ul>
</li>
<li><p>助记符</p>
<ul>
<li>表达指令、伪指令的易于记忆的符号。</li>
</ul>
</li>
<li><p>操作数</p>
<ul>
<li>必须以数字开头, 不能以字母开头。<br>可选项。</li>
<li>可以有多个, 之间用逗号分隔。</li>
</ul>
</li>
<li><p>注释</p>
<ul>
<li>由分号“;”开头, 直到语句行的结尾。</li>
<li>汇编程序对注释不会做任何处理, 但适当的注释可以增加源程序的可读性。</li>
</ul>
</li>
<li><p>保留字(reserved word)</p>
<ul>
<li>汇编程序已经使用的标识符, 也称关键字。</li>
</ul>
<p>主要有：</p>
<ul>
<li>指令助记符, 如MOV</li>
<li>伪指令助记符, 如DB</li>
<li>操作符, 如OFFSET</li>
<li>寄存器名, 如AX</li>
</ul>
</li>
<li><p>分隔符</p>
<ul>
<li>语句的4个组成部分要用分隔符分开。</li>
<li>标号后用冒号, 注释前用分号。</li>
<li>操作数之间使用逗号分隔。</li>
<li>其他部分通常采用空格或制表符。</li>
<li>多个空格和制表符的作用与一个相同</li>
</ul>
</li>
</ul>
<h3 id="数据与表达式"><a href="#数据与表达式" class="headerlink" title="数据与表达式"></a>数据与表达式</h3><ul>
<li><p>数据是操作数的基本组成部分。</p>
</li>
<li><p>汇编语言中的操作数主要有：</p>
<ul>
<li>寄存器</li>
<li>存储单元</li>
<li>常量</li>
<li>变量</li>
<li>标号</li>
<li>表达式</li>
</ul>
</li>
</ul>
<h3 id="常量"><a href="#常量" class="headerlink" title="常量"></a>常量</h3><ul>
<li>常量就是出现在汇编程序中的固定值。<ul>
<li>分类</li>
<li>数字常量</li>
<li>字符串常量</li>
</ul>
</li>
</ul>
<h4 id="数字常量"><a href="#数字常量" class="headerlink" title="数字常量"></a>数字常量</h4><ul>
<li>数字常量指由10、16和2进制形式表达的数值。</li>
<li>各种进制的数据以后缀字母区分, 默认不加后缀字母的是十进制数。</li>
<li><strong>凡是以A~F开始的16进制数, 须在前面加上数字0！</strong></li>
</ul>
<h4 id="字符串常量"><a href="#字符串常量" class="headerlink" title="字符串常量"></a>字符串常量</h4><ul>
<li>字符串常量是用单引号或双引号括起来的单个字符或多个字符。</li>
<li>其数值是每个字符对应的ASCII码值。</li>
</ul>
<h3 id="变量"><a href="#变量" class="headerlink" title="变量"></a>变量</h3><ul>
<li>变量实质上是指内存单元的数据。</li>
</ul>
<ul>
<li>变量需要事先定义才能使用, 定义后的变量可利用变量名等方法引用其中的数据。</li>
<li>每个变量具有三种属性：<ul>
<li>段：变量所在段的段基地址。</li>
<li>偏移量：变量的段内偏移量。</li>
<li>类型：可以是BYTE、WORD、DWORD。</li>
</ul>
</li>
</ul>
<h3 id="标号"><a href="#标号" class="headerlink" title="标号"></a>标号</h3><ul>
<li>标号是存储某条指令的存储单元的符号地址。</li>
<li>它是由标识符后面跟一个冒号来定义的。</li>
<li>通常用作转移指令的目标地址。</li>
<li>例如:<pre><code>START: MOV BX, 1234H
</code></pre></li>
<li>作为存储单元的符号地址, 具有三种属性<ul>
<li>段、偏移量, 和变量相同。</li>
<li>类型：NEAR和FAR。</li>
</ul>
</li>
</ul>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2020/03/30/分类模型/" rel="next" title="分类模型">
                <i class="fa fa-chevron-left"></i> 分类模型
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2020/04/06/Qt中-pro文件/" rel="prev" title="Qt中.pro文件">
                Qt中.pro文件 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Kai</p>
              <p class="site-description motion-element" itemprop="description">这里我会放一些平常学习积累的东西，我的邮箱是hxk0912@foxmail.com</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">129</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">38</span>
                  <span class="site-state-item-name">categories</span>
                </a>
              </div>
            

            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#汇编语言源程序格式"><span class="nav-number">1.</span> <span class="nav-text">汇编语言源程序格式</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#汇编源程序结构特点"><span class="nav-number">1.1.</span> <span class="nav-text">汇编源程序结构特点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#语句类型"><span class="nav-number">1.2.</span> <span class="nav-text">语句类型</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#指令性语句"><span class="nav-number">1.2.1.</span> <span class="nav-text">指令性语句</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#指示性语句"><span class="nav-number">1.2.2.</span> <span class="nav-text">指示性语句</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#指令与伪指令"><span class="nav-number">1.3.</span> <span class="nav-text">指令与伪指令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#数据与表达式"><span class="nav-number">1.4.</span> <span class="nav-text">数据与表达式</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#常量"><span class="nav-number">1.5.</span> <span class="nav-text">常量</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#数字常量"><span class="nav-number">1.5.1.</span> <span class="nav-text">数字常量</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#字符串常量"><span class="nav-number">1.5.2.</span> <span class="nav-text">字符串常量</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#变量"><span class="nav-number">1.6.</span> <span class="nav-text">变量</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#标号"><span class="nav-number">1.7.</span> <span class="nav-text">标号</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Kai</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  

</body>
</html>
